package day06;

import java.io.RandomAccessFile;

import org.junit.Test;

/**
 * 创建一个"raf.dat"的文件，并在其中写出一个int的最大值，long的最大值，
 * 然后将其分别读取出来并输出
 * @author Bonnie
 *
 */
public class Test08 {
	@Test
	public void test() throws Exception {
		RandomAccessFile raf = new RandomAccessFile("raf.dat", "rw");
		String str = "int的最大值：" + Integer.MAX_VALUE + '\n' + " long的最大值：" + Long.MAX_VALUE;
		byte[] bs1 = str.getBytes();
		byte[] bs2 = new byte[1024 * 1024];
		raf.write(bs1);
		raf.seek(0);
		int len = -1;
		while ((len = raf.read(bs2)) != -1) {
			String ss = new String(bs2, 0, len);
			System.out.print(str);
		}
		/*raf.writeInt(Integer.MAX_VALUE);
		raf.writeLong(Long.MAX_VALUE);
		raf.seek(0);
		int i = raf.readInt();
		long l = raf.readLong();
		System.out.println(i);
		System.out.println(l);*/
		raf.close();
	}
}
